package com.myway.core.spring;

import java.util.Locale;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;



public class MessageUtil {
    private  ReloadableResourceBundleMessageSource source;
    
    public MessageUtil() {
    }
    
    public ReloadableResourceBundleMessageSource getSource() {
        return source;
    }
    
    public void setSource(ReloadableResourceBundleMessageSource source) {
        this.source = source;
    }
    
    public String getMessage(String msgKey) {
        try {
            
            Locale locale = Locale.getDefault();
            return source.getMessage(msgKey, null, locale);
        } catch (Throwable t) {
            return "::Missing key-"+msgKey;
        }
    }
    
    public String getMessage(String msgKey, String... replace) {
        try {
            Locale locale = Locale.getDefault();
            String m = source.getMessage(msgKey, replace, locale);
            return m;
        } catch (Throwable t) {
            return "::Missing key-" +msgKey;
        }
    }
    
    
    
    
    
}
